Page({
  data:{
    appId:'',
    appName:'',
    recordId:'',
    pageTitle:'',
    sections:[],
    metaDate:'',
    metaApplicant:'',
    reason:''
  },
  onLoad(options){
    const appId=options.appId||options.app_id||''
    const appName=decodeURIComponent(options.appName||options.app_name||'')
    const recordId=options.recordId||''
    this.setData({appId,appName,recordId})
    this.initPage()
  },
  initPage(){
    const title=`审批处理：${this.data.appName}`
    const sections=this.buildDetailByAppId(this.data.appId,this.data.recordId)
    const meta={date:'2025-11-27',applicant:'庄嘉豪'}
    this.setData({pageTitle:title,sections,metaDate:meta.date,metaApplicant:meta.applicant})
  },
  buildDetailByAppId(appId,recordId){
    const id=String(appId)
    const base=(pairs)=>[{id:'base',name:'基本信息',fields:pairs}]
    if(id==='27'){
      return [
        {id:'base',name:'基本信息',fields:[
          {id:'title',label:'标题',value:`车辆设备报备-${recordId}`},
          {id:'number',label:'编号',value:'VEH-2025-001'},
          {id:'applicant',label:'申请人',value:'庄嘉豪'},
          {id:'department',label:'部门',value:'信息技术部'}
        ]},
        {id:'vehicle',name:'车辆信息',fields:[
          {id:'plate',label:'车牌号',value:'苏A12345'},
          {id:'property',label:'车辆性质',value:'公司车辆'},
          {id:'reportType',label:'报备类型',value:'外出'}
        ]},
        {id:'attachments',name:'附件',fields:[
          {id:'file1',label:'附件1',value:'出车申请单.pdf'}
        ]},
        {id:'flow',name:'审批节点',fields:[
          {id:'node1',label:'部门负责人',value:'待处理'},
          {id:'node2',label:'中心副总',value:'待处理'}
        ]}
      ]
    }
    if(id==='28'){
      return [
        {id:'base',name:'基本信息',fields:[
          {id:'subject',label:'会议主题',value:`会议申请-${recordId}`},
          {id:'location',label:'会议地点',value:'A会议室'},
          {id:'convener',label:'召集人',value:'庄嘉豪'},
          {id:'attendees',label:'参会人员',value:'张三、李四'}
        ]},
        {id:'time',name:'时间',fields:[
          {id:'start',label:'开始时间',value:'2025-11-28 09:00'},
          {id:'end',label:'结束时间',value:'2025-11-28 11:30'}
        ]},
        {id:'agenda',name:'议程序号1',fields:[
          {id:'topic',label:'议题',value:'项目进度'},
          {id:'reporter',label:'汇报人',value:'李四'}
        ]}
      ]
    }
    if(id==='29'){
      return [
        {id:'base',name:'基本信息',fields:[
          {id:'title',label:'标题',value:`支出预算申请-${recordId}`},
          {id:'department',label:'申请部门',value:'信息技术部'},
          {id:'budgetMonth',label:'费用月份',value:'2025-11'}
        ]},
        {id:'budget',name:'预算信息',fields:[
          {id:'category',label:'预算类别',value:'办公'},
          {id:'amount',label:'预算金额',value:'12000.00'},
          {id:'reason',label:'申请事由',value:'采购办公设备'}
        ]}
      ]
    }
    if(id==='31'){
      return [
        {id:'base',name:'基本信息',fields:[
          {id:'title',label:'标题',value:`员工假期申请-${recordId}`},
          {id:'applicant',label:'申请人',value:'庄嘉豪'},
          {id:'department',label:'申请部门',value:'信息技术部'},
          {id:'position',label:'职务',value:'一级助理'}
        ]},
        {id:'leave',name:'假期信息',fields:[
          {id:'leaveType',label:'假期类型',value:'年假'},
          {id:'reason',label:'请假事由',value:'个人事务'}
        ]},
        {id:'detail',name:'请假明细',fields:[
          {id:'start',label:'开始日期',value:'2025-11-28'},
          {id:'end',label:'结束日期',value:'2025-11-29'},
          {id:'slot',label:'时间段',value:'全天'},
          {id:'days',label:'合计工作日',value:'2'}
        ]}
      ]
    }
    if(id==='32'){
      return [
        {id:'base',name:'基本信息',fields:[
          {id:'title',label:'标题',value:`员工辞职申请-${recordId}`},
          {id:'department',label:'申请部门',value:'信息技术部'},
          {id:'position',label:'职位',value:'一级助理'}
        ]},
        {id:'reason',name:'辞职原因',fields:[
          {id:'resignReason',label:'原因',value:'个人发展'},
          {id:'resignDate',label:'本人于',value:'2025-11-27'}
        ]}
      ]
    }
    if(id==='36'){
      return [
        {id:'base',name:'基本信息',fields:[
          {id:'title',label:'标题',value:`物资采购申请-${recordId}`},
          {id:'department',label:'申请部门',value:'信息技术部'},
          {id:'supplier',label:'供应商',value:'供应商A'}
        ]},
        {id:'items',name:'采购明细',fields:[
          {id:'item',label:'物资',value:'笔记本电脑'},
          {id:'qty',label:'数量',value:'2'},
          {id:'total',label:'金额',value:'12000.00'}
        ]}
      ]
    }
    if(id==='38'){
      return [
        {id:'base',name:'基本信息',fields:[
          {id:'title',label:'标题',value:`差旅费报销-${recordId}`},
          {id:'applicant',label:'申请人',value:'庄嘉豪'},
          {id:'applyDate',label:'申请日期',value:'2025-11-27'}
        ]},
        {id:'trip',name:'行程信息',fields:[
          {id:'depart',label:'出发',value:'2025-11-20 08:30 南京'},
          {id:'arrive',label:'到达',value:'2025-11-20 11:00 上海'}
        ]},
        {id:'expense',name:'费用信息',fields:[
          {id:'transport',label:'交通费',value:'300.00'},
          {id:'lodging',label:'住宿费',value:'200.00'},
          {id:'other',label:'其他',value:'60.00'},
          {id:'total',label:'报销总额',value:'560.00'}
        ]}
      ]
    }
    if(id==='39'){
      return [
        {id:'base',name:'基本信息',fields:[
          {id:'title',label:'标题',value:`费用报销-${recordId}`},
          {id:'department',label:'部门',value:'信息技术部'}
        ]},
        {id:'items',name:'报销明细',fields:[
          {id:'type',label:'费用类型',value:'餐饮'},
          {id:'amount',label:'金额',value:'120.00'},
          {id:'date',label:'日期',value:'2025-11-22'}
        ]}
      ]
    }
    if(id==='40'){
      return [
        {id:'base',name:'基本信息',fields:[
          {id:'title',label:'标题',value:`请款申请-${recordId}`},
          {id:'project',label:'关联项目',value:'项目A'},
          {id:'contractNo',label:'合同编号',value:'HT-2025-001'}
        ]},
        {id:'payee',name:'收款信息',fields:[
          {id:'payee',label:'收款单位',value:'某公司'},
          {id:'bankAccount',label:'账号',value:'6217*********'},
          {id:'bankName',label:'开户行',value:'招商银行'}
        ]},
        {id:'amount',name:'金额',fields:[
          {id:'applyAmount',label:'请款金额',value:'50000.00'}
        ]}
      ]
    }
    if(id==='41'){
      return [
        {id:'base',name:'基本信息',fields:[
          {id:'title',label:'标题',value:`借款申请-${recordId}`},
          {id:'purpose',label:'借款用途',value:'差旅备用'},
          {id:'returnDate',label:'归还日期',value:'2025-12-15'}
        ]},
        {id:'payee',name:'收款信息',fields:[
          {id:'payee',label:'收款人',value:'张三'},
          {id:'bankAccount',label:'账号',value:'6217*********'},
          {id:'bankName',label:'开户行',value:'建设银行'}
        ]},
        {id:'amount',name:'金额',fields:[
          {id:'loanAmount',label:'借款金额',value:'10000.00'}
        ]}
      ]
    }
    if(id==='42'){
      return [
        {id:'base',name:'基本信息',fields:[
          {id:'title',label:'标题',value:`经代缴款-${recordId}`},
          {id:'category',label:'缴款类别',value:'契税'},
          {id:'amount',label:'缴款金额',value:'8000.00'}
        ]},
        {id:'customer',name:'客户/项目',fields:[
          {id:'customer',label:'客户',value:'某客户'},
          {id:'project',label:'项目',value:'项目B'}
        ]}
      ]
    }
    return [
      {id:'base',name:'基本信息',fields:[
        {id:'title',label:'标题',value:`通用申请-${recordId}`},
        {id:'applicant',label:'申请人',value:'庄嘉豪'},
        {id:'date',label:'申请日期',value:'2025-11-27'}
      ]},
      {id:'business',name:'业务信息',fields:[
        {id:'category',label:'类别',value:'通用'},
        {id:'desc',label:'说明',value:'—'}
      ]},
      {id:'attachments',name:'附件',fields:[
        {id:'file1',label:'附件1',value:'说明.docx'}
      ]}
    ]
  },
  onReasonInput(e){this.setData({reason:e.detail.value||''})},
  onApprove(){
    if(!this.data.reason||!this.data.reason.trim()){
      wx.showToast({title:'请输入审批理由',icon:'none'});return
    }
    wx.showLoading({title:'提交中...'})
    setTimeout(()=>{wx.hideLoading();wx.showToast({title:'已同意',icon:'success'});setTimeout(()=>{wx.navigateBack()},1200)},800)
  },
  onReject(){
    if(!this.data.reason||!this.data.reason.trim()){
      wx.showToast({title:'请输入审批理由',icon:'none'});return
    }
    wx.showLoading({title:'提交中...'})
    setTimeout(()=>{wx.hideLoading();wx.showToast({title:'已驳回',icon:'success'});setTimeout(()=>{wx.navigateBack()},1200)},800)
  }
})
